package cn.baiweigang.uu.db.mapper;

import cn.baiweigang.uu.db.dataobj.StockInfoDo;
import cn.baiweigang.uu.enums.StrategyEnum;
import org.apache.ibatis.annotations.*;

import java.util.List;

public interface AnalyseDayInfoMapper {

    @Delete("delete from stock_analyse_day_info where ds=#{ds} and cl=#{cl}")
    void delete(@Param("ds") String ds, @Param("cl") StrategyEnum cl);

    @Insert({"<script>",
            "insert into stock_analyse_day_info(updatetime,dm,ds,cl,mc,pm,strategy) values",
            "<foreach collection='stockInfoDoList' item='stockInfoDo' index='index' separator=','>",
            "(NOW(),#{stockInfoDo.dm},#{stockInfoDo.ds},#{stockInfoDo.cl},#{stockInfoDo.mc},#{stockInfoDo.pm},#{stockInfoDo.strategy})",
            "</foreach>",
            "</script>"
    })
    void insertBatch(@Param("stockInfoDoList") List<StockInfoDo> stockInfoDoList);

    @Select("select * from stock_analyse_day_info where ds >= #{ds} and cl=#{cl} order by ds desc")
    List<StockInfoDo> queryByDsAndCl(@Param("ds") String ds, @Param("cl") StrategyEnum cl);

    @Update("update stock_analyse_day_info set updatetime = NOW(), pm = #{pm} where id = #{id} ")
    void updatePm(@Param("id") String id, @Param("pm") int pm);

    @Select("select * from stock_analyse_day_info where ds>=#{ds} and cl=#{cl} order by pm asc ")
    List<StockInfoDo> queryOrderByPm(@Param("ds") String ds,@Param("cl") StrategyEnum cl);
}
